//
//  GHAccountSafeViewController.m
//  GodHorses
//
//  Created by Mac on 2017/11/16.
//  Copyright © 2017年 stoneobs@icloud.com. All rights reserved.
//

#import "GHAccountSafeViewController.h"
#import "GHVerifyViewController.h"
#import "GHChangePhoneViewController.h"
#import "GHVertifyPhoneViewController.h"
#import "GHSetPwdViewController.h"
#import "GHChangePayPwdViewController.h"
@interface GHAccountSafeViewController ()
@property(nonatomic, strong) NSArray                     *dataSouce;
@end

@implementation GHAccountSafeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"账号安全";
    self.dataSouce = @[
                       [[GHTableEasyModel alloc] initWithTextString:@"更改绑定手机号" detailString:@"183****1887"],
                       [[GHTableEasyModel alloc] initWithTextString:@"设置登录密码" detailString:@""],
                       ];
    if ([self.userModel.user_type isEqualToString:@"3"]) {
        self.dataSouce = @[
                           [[GHTableEasyModel alloc] initWithTextString:@"更改绑定手机号" detailString:@"183****1887"],
                           [[GHTableEasyModel alloc] initWithTextString:@"设置登录密码" detailString:@""],
                           [[GHTableEasyModel alloc] initWithTextString:@"设置支付密码" detailString:@""],
                           ];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma --mark UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.dataSouce.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 44;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    return 10;
}
- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return [UIView new];
}
- (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return [UIView new];
}
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString * reuseIdentifier =  @"cell";
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
        
    }
    cell.textLabel.textColor = UIColorFromRGBA(0x333333);
    cell.textLabel.font = [UIFont systemFontOfSize:14];
    cell.detailTextLabel.font = [UIFont systemFontOfSize:13];
    cell.detailTextLabel.textColor = UIColorFromRGBA(0x999999);
    
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
    GHTableEasyModel * model = self.dataSouce[indexPath.row];
    cell.textLabel.text = model.textString;
    cell.detailTextLabel.text = model.detailString;
    return cell;
}
#pragma --mark UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    //更改手机号
    if (indexPath.row == 0) {
         [self.navigationController pushViewController:[GHVertifyPhoneViewController new] animated:YES];
    }
    //密码
    if (indexPath.row == 1) {
        [self.navigationController pushViewController:[GHSetPwdViewController new] animated:YES];
    }
    //密码
    if (indexPath.row == 2) {
        [self.navigationController pushViewController:[GHChangePayPwdViewController new] animated:YES];
    }
    [self.tableView deselectRowAtIndexPath:indexPath animated:NO];
}


@end
